//比较2个对象是否相同
export const equal = (o1,o2) => {
    var props1 = Object.getOwnPropertyNames(o1);
    var props2 = Object.getOwnPropertyNames(o2);
    if (props1.length != props2.length) {
        return false;
    }
    for (var i = 0,max = props1.length; i < max; i++) {
        var propName = props1[i];
        if (o1[propName] !== o2[propName]) {
            return false;
        }
    }
    return true;
}

// 获取当前日期
export function getNowDate(str) {
    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();

    if (month <= 9) {
        month = "0" + month;
    }
    if (strDate <= 9) {
        strDate = "0" + strDate;
    }
    
    if(str){
        if(str == 'str') {
            return year + '年' + month + '月' + strDate + '日';
        }
        return year + str + month + str + strDate;
    }
    return year + '-' + month + '-' + strDate;
    
}

// 日期增加函数
export function addDate(date, days, str) {
    var d = new Date(date);
    d.setDate(d.getDate() + days)
    var year = d.getFullYear();
    var month = d.getMonth() + 1;
    var strDate = d.getDate();
    if (month <= 9) {
        month = "0" + month;
    }
    if (strDate <= 9) {
        strDate = "0" + strDate;
    }
    if(str){
        return year + str + month + str + strDate;
    }else{
        return year + '-' + month + '-' + strDate;
    }
}
	
